#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
    int N, n, num = 1;
    int a[20][20] = { 0 };
    scanf("%d", &N);
    if (N % 2 != 0)
        a[N / 2][N / 2] = N * N;
    for (int n = 0; n < N / 2; n++)
    {
        for (int j = n; j < N - n - 1; j++)
        {
            a[n][j] = num++;
        }
        for (int i = n; i < N - n - 1; i++)
        {
            a[i][N - n - 1] = num++;
        }
        for (int j = N - n - 1; j >= n + 1; j--)
        {
            a[N - n - 1][j] = num++;
        }
        for (int i = N - n - 1; i >= n + 1; i--)
        {
            a[i][n] = num++;
        }
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            printf("%5d", a[i][j]);
        }
        puts("\n");
    }
    return 0;
}